<%-- 
    Document   : specialType
    Created on : 2011-4-10, 16:49:38
    Author     : LBH
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.news.util.Pager"%>
<%@page import="com.news.bean.NewsType"%>
<%@page import="com.news.bean.News"%>
<%@page import="com.news.dao.impl.*" %>
<%@page import="java.util.*" %>

<html>
    <head>
        <script type="text/javascript" src="../jquery.js"></script>

        <%! int perSize = 5;%>
        <title>list</title>

        <script type="text/javascript">
            function page(sender){
                try{
                    var url='../PagerServlet?callback=?';
                    var curr=$("#curr").attr("value");
                    var frame='<tr id="result"><td><input name="id" type="hidden" id="col_1" value="col_1"></td><td><a href="tempContent.jsp?id=col_1.jpg" target="_blank"><img src="getimg.jsp?id=col_1" border=0 width=120 height=150 onerror=\"this.src=\'../img/nopic.jpg\'\"></a></td><td width="50%"><img src="http://down.zhbit.com/skin/default/images/listjt.gif" width="9" height="9" align="absmiddle"><span style="cursor:hand; border-bottom:#336699  solid 1px;" onclick="window.open("newstext.jsp?newsid=col_1")"><font size="2" color="#336699">col_2</font></span></td><td width="15%"><font size="2" color="#336699">col_3</font></td></tr>';
                    frame=encodeURIComponent(frame);
                    jQuery.getJSON(url,{

                        type : sender.value,
                        current : curr,
                        SQL : 'select id,title,dates from news',
                        perSize : <%=perSize%>,
                        frames : frame
                    }, function(data){
                        try{
                            var result=decodeURIComponent(data.sucess);
                            result=result.replace(/\+/g,' ');
                            $("tr[id='result']").remove();
                            $('#page').before(result);
                            $('#curr').attr({value:data.current});
                        }catch(err){
                            alert(err.message);
                        }
                    });
                }catch(err){
                    alert(err.message);
                }

            }
        </script>
        <LINK href="images/class.css" type='text/css' rel=stylesheet>
    </head>
    <body>
        <%
            String newstypeid = request.getParameter("newstypeid");
            int sort = Integer.parseInt(newstypeid);
            NewsType newstype = new NewsTypeDaoImpl().getR(sort);
        %>

        <div id="softlist">
            <H2><%=newstype.getName()%></H2>
            <table width="100%" border="0" cellspacing="1" cellpadding="3">
                <%
                int PageNo = 1;
                List<News> list = new NewsDaoImpl().getBySort(sort);
                if (list != null && list.size() > 0) {
                    int i = 1;
                    for (News news : list) {
                        if (i > perSize) {
                            break;
                        }
                        int bil = i + (PageNo - 1) * 3;
                %>
               
                <tr id="result">
                    <td><input name="id" type="hidden" id="<%=news.getId()%>" value="<%=news.getId()%>"></td>
                    <td>
                        <a href='tempContent.jsp?id=<%=news.getId()%>.jpg' target='_blank'>
                            <img src='getimg.jsp?id=<%=news.getId()%>' border=0 width=120 height=150 onerror="this.src='../img/nopic.jpg'">
                        </a>
                    </td>
                    <td width="50%"><img src="http://down.zhbit.com/skin/default/images/listjt.gif" width="9" height="9" align="absmiddle">
                        <span style="cursor:pointer; border-bottom:#336699  solid 1px;" onclick="window.open('newstext.jsp?newsid=<%=news.getId()%>')">
                            <font size="2" color="#336699"><%=news.getTitle()%></font></span>
                    </td>
                    <td width="15%"><font size="2" color="#336699"><%=news.getDates()%></font></td>
                </tr>
                <%i++;
                    }
                }%>
            </table>
            <div id="page">
                <input type="hidden" name="curr" id="curr" value="0" />
                <table align="center"><tr>
                        <td><input type="button" value="首页" onclick="page(this)"></td>
                        <td><input type="button" value="上一页" onclick="page(this)"></td>
                        <td><input type="button" value="下一页" onclick="page(this)"></td>
                        <td><input type="button" value="尾页" onclick="page(this)"></td>
                    </tr></table>

            </div>
        </div>
    </body>
</html>
